<?php
class LZ_Config
{
	var $table = "config";
	
	var $name = 'name';
	var $value = 'value';
	var $group_id = 'group_id';
	var $id = 'config_id';
	
	var $group = 0;
	
	function LZ_Config()
	{
		$this->table = LZ_MYSQL_PREFIX.$this->table;
	}
	
	function get($name)
	{
		global $db;
		$sql = make_select_sql($this->table, array(
			$this->group_id => $this->group,
			$this->name => $name,
		));
		return $db->get_one($sql);
	}
	
	function set($name,$value,$description)
	{
		global $db;
		$sql = "DELETE FROM $this->table WHERE $this->name='$name' && $this->group_id='$this->group' LIMIT 1";
		$db->query($sql);
		$sql = make_insert_sql($this->table, array('name' =>$name,'value'=>$value, 'description'=>$description));
		return $db->query($sql);
	}
	
	function delete($id)
	{
		global $db;
		$sql = "DELETE FROM $this->table WHERE $this->id ='$id' LIMIT 1";
		return $db->query($sql);
	}
	
	function get_list()
	{
		global $db;
		$sql = make_select_sql($this->table, array('group_id'=>$this->group));
		return $db->get_all($sql);
	}
}
?>